<!DOCTYPE html>
<html class="">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1,user-scalable=no,maximum-scale=1,initial-scale=1"/>
    <title>{$item['title']}</title>
    <link type="text/css" rel="stylesheet" href="{$file}/images/index.css">
    <script src="{$file}/images/jquery-2.1.4.min.js"></script>
    {if $item['isShowSlide'] == 2}
    <script src="{$file}/images/jquery.carouFredSel.js"></script>
    {/if}
    <style>
        #loading{background-color: #f0c600;height: 100%;width: 100%;position: fixed;z-index: 1;margin-top: 0px;top: 0px;}
        #loading-center{width: 100%;height: 100%;position: relative;}
        #loading-center-absolute {position: absolute;left: 50%;top: 50%;height: 150px;width: 150px;margin-top: -75px;margin-left: -75px;-moz-border-radius: 50% 50% 50% 50%;-webkit-border-radius: 50% 50% 50% 50%;border-radius: 50% 50% 50% 50%;}
        .object{width: 20px;height: 20px;background-color: #FFF;position: absolute;-moz-border-radius: 50% 50% 50% 50%;-webkit-border-radius: 50% 50% 50% 50%;border-radius: 50% 50% 50% 50%;-webkit-animation: animate 0.8s infinite;animation: animate 0.8s infinite;}
        #object_one {top: 19px;left: 19px;}
        #object_two {top: 0px;left: 65px;-webkit-animation-delay: 0.1s;animation-delay: 0.1s;}
        #object_three {top: 19px;left: 111px;-webkit-animation-delay: 0.2s;animation-delay: 0.2s;}
        #object_four {top: 65px;left: 130px;-webkit-animation-delay: 0.3s;animation-delay: 0.3s;}
        #object_five {top: 111px;left: 111px;-webkit-animation-delay: 0.4s;animation-delay: 0.4s;}
        #object_six {top: 130px;left: 65px;-webkit-animation-delay: 0.5s;animation-delay: 0.5s;}
        #object_seven {top: 111px;left: 19px;-webkit-animation-delay: 0.6s;animation-delay: 0.6s;}
        #object_eight {top: 65px;left: 0px;-webkit-animation-delay: 0.7s;animation-delay: 0.7s;}
        @-webkit-keyframes animate {25% {-ms-transform: scale(1.5);-webkit-transform: scale(1.5);transform: scale(1.5);}75% {-ms-transform: scale(0);-webkit-transform: scale(0);transform: scale(0);}}
        @keyframes animate {50% {-ms-transform: scale(1.5,1.5);-webkit-transform: scale(1.5,1.5);transform: scale(1.5,1.5);}100% {-ms-transform: scale(1,1);-webkit-transform: scale(1,1);transform: scale(1,1);}}
    </style>

<script>
    $(document).ready(function(){
        {if $nofollow != 1 && $item['isallowip'] != 3}
        $("#loading").delay(1000).fadeOut(500);
        {/if}
    })
</script>

    

</head>
<body>
<style>
.fe-floatback {width: 32px; position: fixed; top: 4px;left:4px; text-align: center; z-index: 1003;}
.fe-floatback a{ display: block; width: 32px; height: 32px;}
.fe-floatback a img{width:32px;height:32px;opacity:0.5;}
{$item['diycss']}
</style>
<div class="fe-floatback">
		<a href="{$backurl}">
			<img src="../core/resource/images/goback.png"></i>
		</a>
</div>
<div id="loading">
    <div id="loading-center">
        <div id="loading-center-absolute">
            <div class="object" id="object_one"></div>
            <div class="object" id="object_two"></div>
            <div class="object" id="object_three"></div>
            <div class="object" id="object_four"></div>
            <div class="object" id="object_five"></div>
            <div class="object" id="object_six"></div>
            <div class="object" id="object_seven"></div>
            <div class="object" id="object_eight"></div>
        </div>
    </div>
</div>


<app>

    <view name="shake-cross" class="shown">
        <section>
            <div class="container">
                <div class="card-list">

                    <div class="card" id="4" card_index="1" style="display: block;">
                        <div class="font" style="border-radius: 0px; background-image: url({if empty($item['backpicurl'])}{$file}/images/defaultbg.jpg{else}{php echo tomedia($item['backpicurl'])}{/if});">

                            <div class="icon">
                                <ul style="list-style: none;">
                                    <li style="padding-bottom: 5px;"><a href="{$awardurl}"><img src="{$file}/images/iconfont-next.png" style="width: 100%;height: 100%;"></a></li>
                                    <li style="padding-bottom: 5px;"><a href="{$infourl}"><img src="{$file}/images/iconfont-gantanhao.png" style="width: 100%;height: 100%;"></a></li>
                                    <li ><img id="rulesimg" src="{$file}/images/iconfont-dianhua.png" style="width: 100%;height: 100%;"></li>
                                </ul>
                            </div>
                            
                            <div class="yaoyiyaobg">
                                <img class="yaoyiyao" src="{$file}/images/iphone2.png" alt="">
                            </div>
                            


                            <div class="ticker">
                                <h3>摇一摇， 摇出惊喜 <i></i></h3>
                                <h4><a style="color:#FFF89E;" id="gamenum" href="#">{if $item['isLimitDrawTimes'] == 2}本活动不限次数{else}还剩<span id="gamespan" class="count">{$leftPlayCount}</span>次机会{/if}</a></h4>
                            </div>

                            <power>
                                <div class="wrapper">
                                {if $item['isShowSlide'] == 2}
                                    <dl id="ticker-1">
                                       {loop $aplist $row}
                                        <dt><img src="{if empty($row['headImg'])}{$file}/images/default.jpg{else}{php echo tomedia($row['headImg'])}{/if}"></dt>
                                        <dd>恭喜{if empty($row['awardinfo'])}匿名网友{else}{$row['awardinfo']}{/if}，赢得红包{$row['awardhb']}元（{php echo date("m-d H:i", $row['createtime'])}）</dd>
                                        {/loop}

                                    </dl>
                                    {/if}
                                </div>
                            </power>
                        </div>

                        <div id="gohome" class="back prepared">
                            <article class="open-redpack pack">
                                <header class="vbox box-vc" id="ad">
                                    <a href=""><img id="adimg" src="{$file}/images/ad1.jpg" alt="loading" {if $item['isadshow']==1}style="width: 100%;height: auto"{else}style="width: 180px;height: auto;margin-left: auto;margin-right: auto;margin-top: 30%;"{/if}></a>
                                </header>
                                <content class="vbox box-vc">
                                    <h4 class="pack-title" id="patitle">哎呀，就差一点点，继续</h4>
                                    <vs style="height:1rem"></vs>
                                    <h4 class="pack-subtitle"></h4>
                                    <!--<vs style="height: 3rem"></vs>-->
                                </content>
                                <footer>
								    <go id="again3" class="button" action="complete" style="display:none; margin-bottom:10px;">点击领取红包</go>
                                    <go id="again" class="button" action="complete">再试试手气</go>
                                    <go id="again2" class="button" action="complete" style="display: none;">打开卡券礼包</go>
                                    
                                </footer>
                            </article>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </view>

</app>


<div id="bg-flower">
    <audio preload="auto" id="audio_male" src="{$file}/audio/male.mp3"></audio>
    <audio preload="auto" id="audio_match" src="{$file}/audio/match.mp3"></audio>
</div>
<!--
{if $item['indexthemes'] == 0}
<div id="shadow" {if $nofollow == 1 || $isshow == 0} style="display: block" {/if}></div>
{else}
<div id="shadow" {if $nofollow == 1} style="display: block" {/if}></div>
{/if}
-->
<div class="phone_tip" id="phone_tip">
    <div class="share" style="width: 90%;margin-left: auto;margin-right: auto;height: 100%;overflow-y: auto;">
        <div class="r" style="margin-top: 30%">
            <p style="color:#eede04;font-size: 24px;">填写兑奖信息</p>
            <div class="formitem">
                <input type="text" name="realname" value="" id="realname" placeholder="填写您的昵称">
            </div>
            <div class="formitem">
                <input type="text" name="tel" value="" id="tel" placeholder="填写您的手机号码">
            </div>
            {if $item['isaddr'] == 1}
            <div class="formitem">
                <input type="text" name="addr" value="" id="addr" placeholder="填写联系地址">
            </div>
            {/if}

        </div>
        <div class="yes" id="phoneyes" style="margin-bottom: 30px">
            <button class="back" onclick="check()"  type="submit">提交信息</button>
        </div>

    </div>
</div>




{if $item['indexthemes'] == 10}

<div class="time_tip" id="time_tip" {if $isshow == 0}style="display: block" {/if}>
    <div class="share" style="width: 100%;margin-left: auto;margin-right: auto;height: 100%;">
        <div class="rbg" {if $isshow == 0}style="display: block" {/if}>
            {if $item['starttime'] > time()}
                别着急，亲！<br/>
            {php echo date("m月d日 H点i分", $item['starttime'])}
            <br/>才开始摇一摇活动哦。

            {/if}
            {if $isshow == 0 && $item['starttime'] <= time()}
            活动暂停中.....
            <br>很快就会回来的！
            {/if}
        </div>
    </div>
</div>
{/if}



<div class="rules_tip" id="rules_tip" {if $nofollow == 1}style="display: block" {/if}>
    <div class="share" style="width: 90%;height: 100%;overflow-y: auto;margin-left: 5%;margin-right: 5%">
        <div class="r" style="margin-top: 20px;">
            {if $nofollow != 1}
            <p style="color:#eede04;font-size: 24px;text-align: center;margin-bottom: 20px;">活动规则</p>

            {$item['content']}

            {else}

            <div style="text-align: center;margin-top: 40%;">
                <img src="{$erwemaimg}" style="width: 60%;height: auto" alt="">
                <span style="display: inline-block;width: 62%;line-height: 24px;margin-top: 15px;">{$erwemaword}</span>
            </div>


            {/if}
        </div>
        {if $nofollow != 1}
        <div class="yes" id="phoneyes" style="margin-bottom: 30px">
            <button class="back" id="rulesclose">关闭</button>
        </div>
        {/if}
    </div>
</div>
</body>
<script type="text/javascript">
var file = '{php echo $file}';
var id = '{php echo $e}';
var token = '{php echo $token}';
var leftPlayCount = '{php echo $leftPlayCount}';
var welcomeurl = '{php echo $welcomeurl}';
var ajaxurl = "../api.php?this=custom&token="+token+"&plugin=jy_h5game&action=chouhb&rid="+id;
$(function () {
            var u = navigator.userAgent, app = navigator.appVersion;
            var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
            // var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
            if (isAndroid) {
                    setTimeout(function(){  
                     $(window).scrollTop(1);  
                     },0); 

                    var a = new Audio();
                    var b = new Audio();
                    a.src = file+'/audio/male.mp3';
                    b.src = file+'/audio/match.mp3';
                    a.load(); 
                      document.addEventListener("WeixinJSBridgeReady", function () {  
                            WeixinJSBridge.invoke('getNetworkType', {}, function (e) {  
                                b.load(); 
                            });  
                      }, false);  
            }
});
</script>
<script>
var isYao = true;
        // $(".ticker").bind("click", function() {
        //     getrp()
        // });
/*
    $("#again").bind("click", function() {
	

        $.ajax({
            url:"",
            dataType:'json',
            success:function(data){
                var runcode = data['runcode'];
                var shenyu = data['shenyu'];
                if(runcode == 99){
                    if(shenyu == 9999){
                        $('#gamenum').html("本活动不限次数");
                    }else{
                        $('#gamespan').html(shenyu);
                    }
                }else{
                    if(shenyu == 9999){
                        $('#gamenum').html("本活动不限次数");
                    }else{
                        $('#gamespan').html(shenyu);
                    }
                }
            }
        });

        $("#4").addClass("remove");
        setTimeout(function() {
            $("#4").removeClass("remove");
            $("#4").removeClass("get-redpack");
            $("#4").removeClass("get-redpack-coming");
        }, 50);
        setTimeout(function() {
            $("#4").addClass("get-redpack-coming");
        }, 50);

        isYao = true;
    });
*/

    $("#again2").bind("click", function() {
        setTimeout(function () {

            jumpCardUrl();

            setTimeout(function () {

                location.href="";

            },600);

        },1000);
    });
  //  {if $nofollow != 1}

    /*开始抽奖*/
  /*  function getrp() {
	alert('xxxx');


        if(isYao){

            isYao = false;

     audio_male.play();


 
    // audio_male.play();
              

        $.get(ajaxurl, function(data) {

            if(data.runcode == 2){
                alert(data.msg);
                isYao = true;
                return false;
            }

            if(data.runcode == 5){

                $("#shadow").show();
                $("#phone_tip").show();
                return false;

            }

            var imgurl = data.imgurl;

            if(imgurl == "" || imgurl == undefined || imgurl == null){
                var imgurl = file+"/images/lose1.png";
            }

            $("#ad").find("img").attr("src", imgurl);
            $("#ad").find("a").attr("href", data.adurl);

            
            setTimeout(function(){
                audio_match.play();
                $("#gohome").addClass("prepared");
                $("#4").addClass("get-redpack");

            },1200);

            if (data.runcode == 1) {

                $("#patitle").html("恭喜您！获得 <span>" + data.name + "</span>");

            }else if(data.runcode == 11){

                $("#patitle").html("恭喜您！获得 <span>" + data.name + "</span>");

                $("#again").hide();
                $("#again2").show();

            }else{
                $("#patitle").html("哎呀，就差一点点，继续！！");
            }
        },"json")

        }
    };
	
        {/if}
		
		*/
/*开始抽奖*/
function getrp() {
  if(isYao){
   isYao = false;
     audio_male.play();
    // audio_male.play();
     $.get(ajaxurl, function(data) {
            if(data.message.code == 10998){
                alert(data.message.errorMsg);
                isYao = true;
                return false;
            }
            if(data.message.code == 2){

                $("#shadow").show();
                $("#phone_tip").show();
                return false;

            }
            var imgurl = data.imgurl;

			if(imgurl == "" || imgurl == undefined || imgurl == null){
						var imgurl = file+"/images/lose1.png";
			}
			$("#ad").find("img").attr("src", imgurl);
			$("#ad").find("a").attr("href", data.adurl);    
			setTimeout(function(){
						audio_match.play();
						$("#gohome").addClass("prepared");
						$("#4").addClass("get-redpack");

			},1200);
			if (data.message.code == 0) {
						$("#again3").show();
						$("#patitle").html("恭喜您！获得红包 <span>" + data.message.fee + "元</span>");
						 var imgurl = file+"/images/bg-nothing.png";
						 $("#ad").find("img").attr("src", imgurl); 
						 $('#again3').click(function(){
						$.ajax({	
							url : "../api.php?this=custom&token="+token+"&plugin=jy_h5game&action=chouhb&rid="+id+"&fee="+data.message.fee+"&op=sendhb",				
							datatype : 'json',
							type : 'post',
							success : function(data){
								var re = JSON.parse(data);
								//alert(JSON.stringify(re.message));
								if(re.message.res.result_code == 'FAIL'){
									alert('红包发送失败，请联系管理员！');
								}else if(re.message.res.result_code == 'SUCCESS'){
									alert('红包发送成功，请在公众号查收！');
								}else{
									alert('领取余额红包成功，请在会员中心查看');
								}
							}
						});
				
				});         
			}else if(data.message.code == 11){
						$("#patitle").html("恭喜您！获得 <span>" + data.name + "</span>");

						$("#again").hide();
						$("#again2").show();

			}else{
						$("#again3").hide();
						$("#patitle").html("哎呀，就差一点点，继续！！");
			}
			//实时刷新剩余摇一摇次数
			$('#again').click(function(){
				 if(1 == 2){
								$('#gamenum').html("本活动不限次数");
							}else{
								$('#gamespan').html(data.message.leftPlayCount);
							}
							 $("#4").addClass("remove");
				setTimeout(function() {
					$("#4").removeClass("remove");
					$("#4").removeClass("get-redpack");
					$("#4").removeClass("get-redpack-coming");
				}, 50);
				setTimeout(function() {
					$("#4").addClass("get-redpack-coming");
				}, 50);

				isYao = true;
			});
		},"json")
	}
};
</script>
<script>
if(window.DeviceMotionEvent) {
       var speed = 23;
       var x = y = z = lastX = lastY = lastZ = 0;
	   let timer = setTimeout(function () {
			alert('请在设置中开启您设备的"动作和方向访问/陀螺仪"权限，否则您将无法使用本应用');
		}, 500);
        window.addEventListener('devicemotion', function(event){
				   clearTimeout(timer);
				   var acceleration =event.accelerationIncludingGravity;
				   x = acceleration.x;
				   y = acceleration.y;
				   //alert(Math.abs(x-lastX));
				   if(Math.abs(x-lastX) > speed || Math.abs(y-lastY) > speed) {
					  getrp();
				   }
				   lastX = x;
				   lastY = y;
        }, false);
}else{
	alert('您的设备不支持《陀螺仪摇动》功能！');
}
</script>
<script type="text/javascript">
{if $item['isShowSlide'] == 2}
    //横向滚动
    var _scroll = {
        delay: 1000,
        easing: 'linear',
        items: 1,
        duration: 0.04,
        timeoutDuration: 0,
        pauseOnHover: false
    };
    $('#ticker-1').carouFredSel({
        width: 1000,
        align: false,
        items: {
            width: 'variable',
            height: 35,
            visible: 1
        },
        scroll: _scroll
    });
    $('.caroufredsel_wrapper').css('width', '100%');
{/if}
    // setInterval(function(){
    //     $.ajax({
    //         url:"",
    //         dataType:'json',
    //         success:function(data){
    //             var runcode = data['runcode'];
    //             var shenyu = data['shenyu'];
    //             if(runcode == 99){
    //                 if(shenyu == 9999){
    //                     $('#gamenum').html("本活动不限次数");
    //                 }else{
    //                     $('#gamespan').html(shenyu);
    //                 }
    //             }else{
    //                 if(shenyu == 9999){
    //                     $('#gamenum').html("本活动不限次数");
    //                 }else{
    //                     $('#gamespan').html(shenyu);
    //                 }
    //             }
    //         }
    //     })
    // },4000);
    $("#rulesimg").bind("click", function() {
        $("#shadow").show();
        $("#rules_tip").show();
    });

    $("#rulesclose").bind("click", function() {
        $("#shadow").hide();
        $("#rules_tip").hide();
    });


    // form check
    function check() {

        var tel = $("#tel").val();
        var realname = $("#realname").val();
        var addr = $("#addr").val();
        var bValidate = RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|18[0-9]|17[0-9]|14[57])[0-9]{8}$/);
        if (tel == '' || realname == '') {
            alert("请输入手机号码和姓名");
            return;
        }
        if(!bValidate.test(tel)){
            alert("请输入正确手机格式");;
            return;
        }

        var submitData = {
            tel: tel,
            realname: realname,
            addr: addr,
            ac: "settel"
        };
        $.post('', submitData, function(idata) {
            if (idata.success == 1) {
                location.href="";
            } else {
                alert(idata.msg);
                location.href="";
            }
        },"json");
    }


</script>

<!-- 微信分享设置 -->
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
     wx.config({
        debug:false,
        appId: '{$package["appId"]}',
        timestamp: '{$package["timestamp"]}',
        nonceStr: '{$package["nonceStr"]}',
        signature: '{$package["signature"]}',
        jsApiList: [
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareWeibo',
            {if $item['isallowip'] == 3}
            'getLocation'
            {/if}
        ]
    });

    var shareMeta  = {
        title: '{$sharetitle}',
        desc: '{$sharedesc}',
        link: "{$sharelink}",
        imgUrl: "{$shareimg}"
    };

    wx.ready(function(){
         {if $item['isallowip'] == 3}
        wx.getLocation({
            type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
            success: function (res) {
                var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                var speed = res.speed; // 速度，以米/每秒计
                var accuracy = res.accuracy; // 位置精度


                 var submitData = {
                    lat: latitude,
                    lon: longitude,
                    lbsip:"{$item['allowip']}"
                };
                $.post('{php echo $this->createMobileUrl('getlbs', array('id' => $id))}', submitData, function(idata) {
                    if (idata.success == 1) {
                        $("#loading").fadeOut(10);
                    } else {
                        alert(idata.msg);
                        
                    }
                },"json");

            },
            fail:function(){
                alert("获取位置失败,请打开GPS功能！");
            }
        });
        {/if}
        wx.onMenuShareTimeline(shareMeta);
        wx.onMenuShareAppMessage(shareMeta);
        wx.onMenuShareWeibo(shareMeta);
    });


    function jumpCardUrl(){
        var temp = '{$cardArry['cardId']}';
        if(temp == null || temp == '' || temp == undefined){
            return;
        }
        wx.addCard({
            cardList: [{
                cardId: '{$cardArry['cardId']}',
                cardExt: '{"code": "", "openid": "{$cardArry['openid']}", "timestamp": "{$cardArry['timestamp']}","nonce_str":"{$cardArry['nonceStr']}", "signature":"{$cardArry['signature']}"}'
            }], // 需要添加的卡券列表
            success: function (res) {
                var cardList = res.cardList; // 添加的卡券列表信息
            }
        });
    }

</script>



</html>